package qeb.handheldmedical.patient;

import org.json.JSONArray;

import qeb.handheldmedical.R;
import qeb.handheldmedical.adapter.PacsAdapter;
import qeb.handheldmedical.adapter.SlideListView;
import qeb.handheldmedical.helper.WSHelper;
import qeb.handheldmedical.model.InPatient;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class PacsQuery extends Activity {
	private SlideListView slideListView;
	private PacsAdapter adapter;
	InPatient ip = new InPatient();
	private JSONArray jcbgJsonArray;

	private Button btn_title_back;
	private TextView tv_title;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		ip = (InPatient) getIntent().getSerializableExtra("patientinfo");

		setContentView(R.layout.pacsquery);
		initView();
		dataBind();
	}

	private void initView() {
		slideListView = (SlideListView) findViewById(R.id.slideListView2);
		tv_title = (TextView) findViewById(R.id.tv_top_title);
		tv_title.setText(ip.XM + "的检查");
		btn_title_back = (Button) findViewById(R.id.btn_title_back);
		btn_title_back.setOnClickListener(MyOnClickListener);

	}

	/* 系统主菜单点击事件（在院病人、门诊病人等） */
	private OnClickListener MyOnClickListener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			// TODO 自动生成的方法存根
			// Bundle bundle=new Bundle();
			switch (v.getId()) {
			case R.id.btn_title_back:// 返回按钮
				PacsQuery.this.finish();
				break;
			default:
				break;
			}
		}
	};

	private void dataBind() {
		jcbgJsonArray = WSHelper.GetPacsList("2000", "2115", ip.BAH);
		if (jcbgJsonArray != null && jcbgJsonArray.length() > 0) {
			adapter = new PacsAdapter(jcbgJsonArray.length(), PacsQuery.this,
					jcbgJsonArray);

			slideListView.setAdapter(adapter);
		}
	}
}
